<template>
  <div class="type-nav">
    <div class="container">
      <h2 class="all">部分汽车品牌</h2>
      <nav class="nav">
        <span @click="jump(1) ">焦点</span>
        <span @click="jump(2)">为你推荐</span>
        <span @click="jump(3)">最新车型</span>
        <span @click="jump(4)">车评</span>
        <span @click="jump(5)">有趣</span>
      </nav>
      <div class="sort">
        <div class="all-sort-list2">

          <div class="item bo" v-for="B in brands">
            <h3>
              <a href="http://101.43.12.19/#/carSelection">{{B.brandName}}</a>
            </h3>

          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "TypeNav",
  data() {
    return {
      brands: []
    }
  },
  mounted: function() {
    this.$axios.get('/brand/all').then(res => {
      this.brands = res.data.data
      console.log(this.brands)
    })
  },
  methods: {
    jump(id) {
      switch (id) {
        case 1: window.scrollTo({top: 755, behavior: "smooth"}); break;
        case 2: window.scrollTo({top: 1240, behavior: "smooth"}); break;
        case 3: window.scrollTo({top: 1455, behavior: "smooth"}); break;
        case 4: window.scrollTo({top: 1910, behavior: "smooth"}); break;
        case 5: window.scrollTo({top: 2350, behavior: "smooth"}); break;
      }
    }
  }
}
</script>

<style lang="less" scoped>
.type-nav {
  border-bottom: 2px solid #e1251b;

  .container {
    width: 1200px;
    margin: 0 auto;
    display: flex;
    position: relative;

    .all {
      width: 210px;
      height: 45px;
      background-color: #e1251b;
      line-height: 45px;
      text-align: center;
      color: #fff;
      font-size: 14px;
      font-weight: bold;
    }

    .nav {
      span {
        height: 45px;
        margin: 0 22px;
        line-height: 45px;
        font-size: 16px;
        color: #333;
      }
      span:hover {
        cursor: pointer;
        border-bottom: 1px solid #666666;
      }
    }

    .sort {
      position: absolute;
      left: 0;
      top: 45px;
      width: 210px;
      height: 414px;
      background: #fafafa;
      z-index: 999;
      margin-bottom: 10px;

      .all-sort-list2 {
        .item {
          h3 {
            line-height: 30px;
            font-size: 14px;
            font-weight: 400;
            overflow: hidden;
            padding: 0 20px;
            margin: 0;

            a {
              color: #333;
            }
          }

          .item-list {
            display: none;
            position: absolute;
            width: 734px;
            min-height: 460px;
            background: #f7f7f7;
            left: 210px;
            border: 1px solid #ddd;
            top: 0;
            z-index: 9999 !important;

            .subitem {
              float: left;
              width: 650px;
              padding: 0 4px 0 8px;

              dl {
                border-top: 1px solid #eee;
                padding: 6px 0;
                overflow: hidden;
                zoom: 1;

                &.fore {
                  border-top: 0;
                }

                dt {
                  float: left;
                  width: 54px;
                  line-height: 22px;
                  text-align: right;
                  padding: 3px 6px 0 0;
                  font-weight: 700;
                }

                dd {
                  float: left;
                  width: 415px;
                  padding: 3px 0 0;
                  overflow: hidden;

                  em {
                    float: left;
                    height: 14px;
                    line-height: 14px;
                    padding: 0 8px;
                    margin-top: 5px;
                    border-left: 1px solid #ccc;
                  }
                }
              }
            }
          }

          &:hover {
            .item-list {
              display: block;
            }
          }
        }
      }
    }
  }
}
</style>
